﻿using System.Dynamic;
using Basic.FormGatewaryModular.Interface;
using Basic.FormGatewaryModular.Model.QueryForm;
using Basic.FormRemoteModel.QueryForm.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Api
{
    [ApiRouteName("/form/query/form/{name}")]
    internal class QueryFormApi : ApiController
    {
        private readonly IQueryFormService _Service;

        public QueryFormApi ( IQueryFormService service )
        {
            this._Service = service;
        }

        public QueryFormBody GetBody ( [NumValidate("form.id.error", 1)] long formId )
        {
            return this._Service.GetBody(formId);
        }

        public QueryFormRecord GetRecord ( [NumValidate("form.id.error", 1)] long formId, [NumValidate("form.query.record.id.error", 1)] long id )
        {
            return this._Service.GetRecord(formId, id);
        }

        public PagingResult<ExpandoObject> Query ( PagingParam<QueryTableArg> param )
        {
            return this._Service.Query(param, base.UserState.ToCompanyId());
        }
    }
}
